package pl.edu.pw.mini.java2.Communicator.Server;

import java.util.*;

public class ClientsCollection {

	private HashMap<String, ClientHandler> clients = null;

	public ClientsCollection() {
		clients = new HashMap<String, ClientHandler>();
	}

	public synchronized void AddClient(String login, ClientHandler ch) {
		clients.put(login, ch);
	}

	public synchronized void RemoveClient(String login) {
		clients.remove(login);
	}

	public synchronized ClientHandler FindClientHandler(String login) {
		return clients.get(login);
	}
	
	public Object[] GetAllClientsNames(){
		ArrayList<String> list=new ArrayList<String>();			
		for (String key: clients.keySet()){			
			list.add(key);
		}
		return list.toArray();
	}
	
	public int Count(){
		return clients.size();
	}
}